// pages/paySuccessful/paySuccessful.js
const app = getApp()
var api = require('../../../utils/api.js')
var util = require('../../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderInfo: {},
    items: {},
    numbers: '',
    total_fees: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      this.setData({
        oid: options.oid
      })
    this.orderDetails()
  },

//订单详情
  orderDetails: function () {
    var that = this;
    var oid = this.data.oid;
    api.POST({
      params: { "oid": oid },
      url: app.globalData.base_url + 'couponsorder/info',
      success: function (res) {
        if (util.isEmpty(res.data.code)) {
          var productList = res.data.data.productList;
          var productDetails = res.data.data;
          // that.data.item.productList = productList;
          var invoice = productList.every(function (item) {
            return item.return_status == 0
          })
          that.setData({
            invoiceCol: invoice
          })
          that.setData({
            productList: productList,
            productDetails: productDetails
          })
        }
      },
      fail: function (fail) {
        util.showError("网络错误，请检查网络");
      }
    })
  },

  // 完成
  complete: function () {
    wx.switchTab({
      url: '/pages/index/index'
    })
  },
})